package dao;

import mappings.ChemicalComposition;
import mappings.PhaseComposition;
import org.hibernate.SessionFactory;
import org.hibernate.classic.Session;
import org.hibernate.criterion.Restrictions;
import utils.HibernateUtil;

import java.util.List;

public class PhaseCompositionDao
{
    private static SessionFactory sessionFactory = HibernateUtil.getSessionFactory();

    /*
     * Zwraca phase_compositions dla zadanego material_id
     */
    public List<PhaseComposition> getPhaseCompositionsForMaterial(int materialId)
    {
        Session session = sessionFactory.openSession();

        List<PhaseComposition> phaseCompositions = session.createCriteria(PhaseComposition.class)
                .add(Restrictions.eq("material.id", materialId))
                .list();

        session.close();

        return phaseCompositions;
    }
}
